
import	java.io.Console;
import	java.util.Scanner;

public class quanly {
	public	static	void main	(String[]	args){
	int soLuongSV=0;
		 Scanner input = new Scanner(System.in);
	  int[] mssv = new int  [100];
	  String [] hoTen = new String [100];
	  double [] diem = new	double [100];
	
		if((args.length>1) && (args.length==0) ){
			System.out.println("Loi command line");
		}
		else{
			try{
				soLuongSV = Integer.parseInt(args[0]);
			}
			catch(ArrayIndexOutOfBoundsException e){
				System.out.println("Loi nhap commad line");
			}
			
		}
		
		for(int i=0;i<soLuongSV;i++){
			System.out.println("Nhap thong tin sinh vien "+(i+1)+ ": ");
			System.out.print("Ho ten: ");
			hoTen[i]= input.nextLine();
			
			System.out.print("MSSV: ");
			mssv[i]= input.nextInt();
			
			System.out.print("Diem thi: ");
			diem[i]=input.nextDouble();input.nextLine();
		}
	
		
		//In danh sach sinh vien
			System.out.println("|--------------------------------------------|");
			System.out.println("|           Danh sach sinh vien              |");
			System.out.println("|--------------------------------------------|");
			System.out.println("|     HoTen          |   MSSV        | DIEM  |");
			System.out.println("|--------------------------------------------|");
			for(int i=0;i<soLuongSV;i++){
				System.out.printf("|%-20s| %-13d |%7.2f|\n", hoTen[i],mssv[i],diem[i]);
				System.out.println("|--------------------------------------------|");
			}
			
		//Hien thi sinh vien dat duoc diem cao nhat, thap nhat
			System.out.println();
			System.out.println();
			System.out.println("***********************************************");
			double min = diem[0];
			double max	=diem [0];
			int j=0;
			int k=0;
			for(int i=0;i<soLuongSV;i++){
				if(diem[i]>max){
					max=diem[i];
					 j=i;
				}
				if(diem[i]<min){
					min=diem[i];
					 k=i;
				}
			}
			System.out.println("Sinh vien co diem cao nhat: ");
			System.out.println(hoTen[j]+"\t" + mssv[j] +"\t" + diem[j]);
			System.out.println("Sinh vien co diem thap nhat: ");
			System.out.println(hoTen[k]+"\t" + mssv[k] +"\t" + diem[k]);
			
		//Hien thi sinh vien co diem lon hon 4, va trung binh diem ca nhom
			double tongDiem=0;
			System.out.println();
			System.out.println();
			System.out.println("*************************************************");
			System.out.println("Cac sinh vien co diem >=4:");
			for(int i=0;i<soLuongSV;i++){
				if(diem[i]>=4){
					System.out.println(hoTen[i] +"\t" + mssv[i]+ "\t"+ diem[i]);
				}
				else 
					System.out.println("Khong co sinh vien nao");
				tongDiem=tongDiem+diem[i];
			}
			double trungBinh = tongDiem/soLuongSV;
			System.out.println("Diem trung binh cua ca nhom: "+trungBinh);
	}
}




